package com.huawei.appmarket.service.pay.purchase;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import androidx.fragment.app.FragmentActivity;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.card.base.bean.AppInfoBean;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.foundation.store.bean.detail.DetailResponse;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.LayoutData;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.widget.CardListAdapter;
import com.huawei.appgallery.foundation.ui.framework.fragment.AppListFragment;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean.a;
import com.huawei.appmarket.service.appzone.view.widget.TraceEditAppListAdapter;
import com.huawei.appmarket.service.pay.purchase.view.AppZoneEditListFragmentProtocol;
import com.huawei.appmarket.service.pay.purchase.view.AppZoneEditListFragmentProtocol.Request;
import com.huawei.appmarket.service.store.awk.bean.AppZoneTraceInfoCardBean;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import o.cdb;
import o.cdg;
import o.cfv;
import o.cia;
import o.cie;
import o.cih;
import o.cnz;
import o.coa;
import o.cvt;
import o.BaseRequest;
import o.dgm;
import o.Logger;
import o.dof;
import o.dvt;
import o.dwe;
import o.dwj;
import o.ecv;
import o.ecz;
import o.eda;
import o.eei;
import o.CollectCheck;
import o.fho;
import o.fhz;

public class AppZoneEditListFragment extends AppListFragment<AppZoneEditListFragmentProtocol> implements eda {
    private coa ʹ;
    private final Map<String, AppInfoBean> ˊ = new HashMap();
    private int ॱॱ;
    private int ᐝ = 0;
    private d ﹳ = new d();
    private boolean ﾞ;
    private String ﾟ;

    class c implements dwj {
        final /* synthetic */ AppZoneEditListFragment ˎ;

        private c(AppZoneEditListFragment appZoneEditListFragment) {
            this.ˎ = appZoneEditListFragment;
        }

        public void ॱ() {
            Activity ॱˋ = this.ˎ.ॱˋ();
            if (ॱˋ != null && !ॱˋ.isFinishing()) {
                this.ˎ.ॱˋ().finish();
            }
        }

        public void ˎ() {
            Activity ॱˋ = this.ˎ.ॱˋ();
            if (ॱˋ != null && !ॱˋ.isFinishing()) {
                this.ˎ.ॱˋ().finish();
            }
        }
    }

    class d {
        final /* synthetic */ AppZoneEditListFragment ˏ;

        private d(AppZoneEditListFragment appZoneEditListFragment) {
            this.ˏ = appZoneEditListFragment;
        }

        public void ॱ(ResponseBean responseBean) {
            int ˊ = ˊ((AppZoneEditListFragmentProtocol) this.ˏ.ˆ());
            boolean ˋ = ˋ((AppZoneEditListFragmentProtocol) this.ˏ.ˆ());
            int ॱ = this.ˏ.ˊʻ();
            if (1 == ॱ) {
                if (ˊ == 1 && ˋ) {
                    ˊ(responseBean, true, true);
                } else if (ˊ == 0 && ˋ) {
                    ˊ(responseBean, false, true);
                } else if (ˊ == 1 && !ˋ) {
                    ˊ(responseBean, false, true);
                }
            } else if (ॱ != 0) {
            } else {
                if (ˊ == 1 || ˋ) {
                    ˊ(responseBean, true, false);
                }
            }
        }

        private void ˊ(ResponseBean responseBean, boolean z, boolean z2) {
            int ˊ = ˊ((AppZoneEditListFragmentProtocol) this.ˏ.ˆ());
            if (responseBean.getResponseCode() == 0 && responseBean.getRtnCode_() == 0) {
                List<LayoutData> ᐝॱ = ((DetailResponse) responseBean).ᐝॱ();
                if (!CollectCheck.isEmpty(ᐝॱ)) {
                    for (LayoutData ˋ : ᐝॱ) {
                        Iterator it = ˋ.ˋ().iterator();
                        while (it.hasNext()) {
                            CardBean cardBean = (CardBean) it.next();
                            String ॱـ = cardBean.ॱـ();
                            if (z) {
                                if (!TextUtils.isEmpty(ॱـ) && ((cdg) cdb.ॱ(cdg.class)).ॱॱ(ॱـ)) {
                                    it.remove();
                                } else if (ˊ == 1 && !dof.ˋ(ॱـ)) {
                                    if (ˊ(ॱـ)) {
                                        it.remove();
                                    }
                                }
                            }
                            if (z2 && !ˎ(cardBean)) {
                                it.remove();
                            }
                        }
                    }
                }
            }
        }

        private boolean ˎ(CardBean cardBean) {
            BaseDistCardBean baseDistCardBean = (BaseDistCardBean) cardBean;
            if (dof.ॱ(cardBean.ॱـ())) {
                return false;
            }
            return baseDistCardBean.ᐝॱ();
        }

        private boolean ˋ(AppZoneEditListFragmentProtocol appZoneEditListFragmentProtocol) {
            if (appZoneEditListFragmentProtocol != null && appZoneEditListFragmentProtocol.ॱ() != null) {
                return ((Request) appZoneEditListFragmentProtocol.ॱ()).ˌ();
            }
            Logger.ˎ("AppZoneEditListFra", "oCreate appZoneEditListFragmentProtocol is null or request is null!");
            return false;
        }

        private AppInfoBean ˊ(AppZoneTraceInfoCardBean appZoneTraceInfoCardBean) {
            AppInfoBean appInfoBean = new AppInfoBean();
            appInfoBean.ʼ(appZoneTraceInfoCardBean.ʾ());
            appInfoBean.ॱॱ(appZoneTraceInfoCardBean.ʼॱ());
            appInfoBean.ˏ(appZoneTraceInfoCardBean.v_());
            appInfoBean.ˋ(appZoneTraceInfoCardBean.ॱـ());
            appInfoBean.ˎ(appZoneTraceInfoCardBean.ͺˏ());
            appInfoBean.ˊ(appZoneTraceInfoCardBean.ॱˌ());
            appInfoBean.ᐝ(appZoneTraceInfoCardBean.ॱॱ());
            appInfoBean.ʻ(appZoneTraceInfoCardBean.ˉ() + "");
            appInfoBean.ॱ(appZoneTraceInfoCardBean.ˎˎ());
            appInfoBean.ˋ(appZoneTraceInfoCardBean.ˏॱ());
            appInfoBean.ˎ(appZoneTraceInfoCardBean.ˊ());
            appInfoBean.ʻ(appZoneTraceInfoCardBean.ॱᶥ());
            return appInfoBean;
        }

        private void ˎ(ResponseBean responseBean, int i) {
            if (responseBean.getResponseCode() == 0 && responseBean.getRtnCode_() == 0) {
                List<LayoutData> ᐝॱ = ((DetailResponse) responseBean).ᐝॱ();
                if (!CollectCheck.isEmpty(ᐝॱ)) {
                    for (LayoutData ˋ : ᐝॱ) {
                        for (CardBean cardBean : ˋ.ˋ()) {
                            if (cardBean instanceof AppZoneTraceInfoCardBean) {
                                ((AppZoneTraceInfoCardBean) cardBean).ʼ(i);
                            }
                        }
                    }
                }
            }
        }

        private boolean ˎ(String str) {
            if (dof.ˋ(str) || dvt.ˏ().ˋ(str) == null) {
                return false;
            }
            return true;
        }

        private boolean ˊ(String str) {
            cnz o_cnz = cnz.ॱ;
            if (this.ˏ.ʹ != null) {
                o_cnz = this.ˏ.ʹ.ˏ(str);
            }
            return ˎ(str) || o_cnz == cnz.ˏ || o_cnz == cnz.ˊ;
        }

        private int ˊ(AppZoneEditListFragmentProtocol appZoneEditListFragmentProtocol) {
            if (appZoneEditListFragmentProtocol != null && appZoneEditListFragmentProtocol.ॱ() != null) {
                return ((Request) appZoneEditListFragmentProtocol.ॱ()).ˋᐝ();
            }
            Logger.ˎ("AppZoneEditListFra", "oCreate appZoneEditListFragmentProtocol is null or request is null!");
            return -1;
        }
    }

    public void ˏ(Bundle bundle) {
        fhz ˋ = fho.ˏ().ˋ("PackageManager");
        if (ˋ != null) {
            this.ʹ = (coa) ˋ.ॱ(coa.class);
        }
        AppZoneEditListFragmentProtocol appZoneEditListFragmentProtocol = (AppZoneEditListFragmentProtocol) ˆ();
        if (appZoneEditListFragmentProtocol == null || appZoneEditListFragmentProtocol.ॱ() == null) {
            Logger.ˎ("AppZoneEditListFra", "oCreate appZoneEditListFragmentProtocol is null or request is null!");
        } else {
            this.ॱॱ = ((Request) appZoneEditListFragmentProtocol.ॱ()).ˎˎ();
            this.ﾟ = ((Request) appZoneEditListFragmentProtocol.ॱ()).ˍ();
            String userId = UserSession.getInstance().getUserId();
            if (dof.ॱ(this.ﾟ)) {
                this.ﾟ = userId;
            }
            boolean z = (dof.ॱ(this.ﾟ) || dof.ˎ(this.ﾟ, userId)) ? false : true;
            this.ﾞ = z;
        }
        super.ˏ(bundle);
    }

    public void ˋ(ViewGroup viewGroup, LayoutInflater layoutInflater) {
        super.ˋ(viewGroup, layoutInflater);
        this.ͺˎ.setOnItemClickListener(new OnItemClickListener(this) {
            final /* synthetic */ AppZoneEditListFragment ˋ;

            {
                this.ˋ = r1;
            }

            public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
                cie o_cie = (cie) view.getTag();
                if (o_cie != null) {
                    for (int i2 = 0; i2 < o_cie.ˊॱ(); i2++) {
                        cih ˎ = o_cie.ˎ(i2);
                        if (ˎ != null) {
                            this.ˋ.ˏ(5, ˎ);
                        }
                    }
                }
            }
        });
    }

    public View ˋ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View ˋ = super.ˋ(layoutInflater, viewGroup, bundle);
        ˋॱ(true);
        this.ͺˎ.setSelectionFromTop(this.ॱॱ, 0);
        return ˋ;
    }

    public void ˌॱ() {
    }

    public void ˋʼ() {
    }

    public CardListAdapter ˎ(Context context, cia o_cia) {
        return new TraceEditAppListAdapter(context, o_cia);
    }

    public void ˋ(TaskFragment taskFragment, List<cvt> list) {
        Log.i("AppZoneEditListFra", "onPrepareRequestParams nextPageNum = " + this.ˏ);
        ecv ˊ = ecv.ˊ("", this.ˏ, this.ﾞ);
        ˊ.ˏ(30);
        ˊ.setServiceType_(dgm.ˎ(ॱˋ()));
        ˊ.ˊॱ(this.ﾟ);
        if (this.ﾞ) {
            ˊ.ˏ("familymembershare|" + this.ﾟ);
        }
        this.ᐝ = this.ˏ;
        list.add(ˊ);
    }

    private int ˊʻ() {
        AppZoneEditListFragmentProtocol appZoneEditListFragmentProtocol = (AppZoneEditListFragmentProtocol) ˆ();
        if (appZoneEditListFragmentProtocol != null && appZoneEditListFragmentProtocol.ॱ() != null) {
            return ((Request) appZoneEditListFragmentProtocol.ॱ()).ˎˏ();
        }
        Logger.ˎ("AppZoneEditListFra", "oCreate appZoneEditListFragmentProtocol is null or request is null!");
        return 0;
    }

    public boolean ˊ(TaskFragment taskFragment, b bVar) {
        int ॱ = this.ﹳ.ˊ((AppZoneEditListFragmentProtocol) ˆ());
        ResponseBean responseBean = bVar.ˋ;
        this.ﹳ.ˎ(responseBean, ॱ);
        this.ﹳ.ॱ(responseBean);
        ˏ(bVar);
        return false;
    }

    public void ˏ(b bVar) {
        BaseRequest o_cvu = bVar.ˊ;
        ResponseBean responseBean = bVar.ˋ;
        if ((o_cvu instanceof cfv) && (responseBean instanceof DetailResponse)) {
            Logger.ˎ("AppZoneEditListFra", "OnCompleted,fragID:" + this.ʼᐝ + ", reqcmd:" + o_cvu.getMethod_() + ",pagenum:" + this.ˏ + ",type:" + responseBean.getResponseType());
            this.ᶫ = System.currentTimeMillis();
            if (responseBean.getResponseCode() == 0 && responseBean.getRtnCode_() == 0) {
                ˏ((cfv) o_cvu, responseBean);
                return;
            } else {
                ˋ(responseBean);
                return;
            }
        }
        Logger.e("AppZoneEditListFra", "onResponse, req not instanceof DetailRequest or res not instanceof DetailResponse");
    }

    private void ˋ(ResponseBean responseBean) {
        this.ߴ.setVisibility(8);
        if (this.ॱˌ != null) {
            this.ॱˌ.onEvent(responseBean.getResponseCode());
        }
        this.ͺˎ.ॱˊ();
    }

    private void ˏ(cfv o_cfv, ResponseBean responseBean) {
        if (!(ʼʻ() || this.ॱˌ == null)) {
            this.ॱˌ.onEvent(0);
            ˋॱ(true);
            this.ॱˌ = null;
        }
        ॱˋ(true);
        new eei().ॱ(this.י, o_cfv, (DetailResponse) responseBean, false);
        this.י.ͺ();
        if (this.ˏ == 1) {
            this.ͺˎ.setSelection(0);
        }
        if (responseBean.getResponseType() != a.ˋ) {
            this.ˏ++;
        }
        int ˊॱ = this.י.ˊॱ();
        if (this.ᐧॱ != null) {
            this.ᐧॱ.ˋ(this.ʼᐝ, this.י);
        }
        if (this.י.ᐝ() || ˊॱ != 0) {
            if (ˊॱ == 0) {
                ʿˊ();
            }
            this.ߴ.setVisibility(8);
            return;
        }
        this.י.ॱॱ();
        this.י.ˊ(false);
        this.ߴ.setVisibility(0);
    }

    public void ˏ(int i, cih o_cih) {
        if (i == 5) {
            CardBean ˌ = o_cih.ˌ();
            if (ˌ instanceof AppZoneTraceInfoCardBean) {
                AppZoneTraceInfoCardBean appZoneTraceInfoCardBean = (AppZoneTraceInfoCardBean) ˌ;
                if (ˊ(appZoneTraceInfoCardBean) || appZoneTraceInfoCardBean.ꓸ() != 1) {
                    int ॱ = this.ﹳ.ˊ((AppZoneEditListFragmentProtocol) ˆ());
                    if (!dof.ˋ(appZoneTraceInfoCardBean.ˊˋ()) && ॱ == 0) {
                        return;
                    }
                    if (appZoneTraceInfoCardBean.ㆍ() == 1) {
                        appZoneTraceInfoCardBean.ʽ(0);
                        FragmentActivity ॱˋ = ॱˋ();
                        if (ॱˋ instanceof ecz) {
                            ((ecz) ॱˋ).ˊ(ˌ.ॱـ());
                            this.ˊ.remove(ˌ.ॱـ());
                        }
                    } else if (appZoneTraceInfoCardBean.ㆍ() == 0) {
                        appZoneTraceInfoCardBean.ʽ(1);
                        FragmentActivity ॱˋ2 = ॱˋ();
                        if (ॱˋ2 instanceof ecz) {
                            ((ecz) ॱˋ2).ˋ(ˌ.ॱـ());
                            this.ˊ.put(ˌ.ॱـ(), this.ﹳ.ˊ(appZoneTraceInfoCardBean));
                        }
                    }
                } else {
                    return;
                }
            }
            this.י.ͺ();
        }
    }

    private boolean ˊ(AppZoneTraceInfoCardBean appZoneTraceInfoCardBean) {
        if ((appZoneTraceInfoCardBean.ˌ() & 1) == 0 && (appZoneTraceInfoCardBean.ˌ() & 2) == 0) {
            return true;
        }
        return false;
    }

    public void ˋ(View view) {
        if (this.ˊ != null && this.ˊ.size() > 0) {
            dwe o_dwe = new dwe();
            o_dwe.ˋ(this.ˊ);
            o_dwe.ˊ(false);
            o_dwe.ˎ(new c());
            o_dwe.ˊ(ॱˋ(), view);
        }
    }

    public void ʻ(int i) {
    }
}
